const $$ = (function () {
    function getStyle(obj, attr) {
        if (window.getComputedStyle) {
            return window.getComputedStyle(obj, null)[attr];
        }
        return obj.currentStyle[attr];
    }
    
    function animate(oEle, json, callback = () => { }) {
        clearInterval(oEle.timer);
        oEle.timer = setInterval(() => {
            let flag = true;
            let current = 0;
            let target = 0;
            for (let attr in json) {
                current = parseInt(getStyle(oEle, attr));
                target = parseInt(json[attr]);
                if (attr == "opacity") {
                    current = parseFloat(getStyle(oEle, attr)) * 100;
                    target = parseFloat(json[attr]) * 100;
                }
                let step = (target - current) / 10;
                step = step > 0 ? Math.ceil(step) : Math.floor(step);
                if (attr == "zIndex") {
                    oEle.style[attr] = target;
                } else if (attr == "opacity") {
                    oEle.style[attr] = (current + step) / 100;
                   
                    oEle.style.filter = "alpha(opacity=" + (current + step) + ")";
                } else {
                    oEle.style[attr] = current + step + "px";
                }
                if (target != current) {
                    flag = false;
                }
            }
            if (flag) {
                clearInterval(oEle.timer);
                callback();
           
                console.log("end");
            }
        }, 30);
    }
    return {
        getStyle,
        animate
    }
})()